Page({
  data: {
    user: {
      info:'说出口令领取红包',
      
      thumb: ''
    },
    kouling: '哈哈哈',
    bao_info: '按住说出口令',
  },
  onShow: function () {
    let that = this;
    var value = wx.getStorageSync('user');
    if (value) {
      wx.getStorage({
        key: 'user',
        success: function (res) {
          console.log(res);
          that.setData({
            user: res.data
          })
        }
      })
    }
  },
  startRecode: function () {
    var s = this;
    wx.startRecord({
      success: function (res) {
        var tempFilePath = res.tempFilePath;
        s.setData({ recodePath: tempFilePath, isRecode: true });
      },
      fail: function (res) {
        console.log("fail");
        console.log(res);
        //录音失败
      }
    });
  },


  endRecode: function () {//结束录音 
    var s = this;
    wx.stopRecord();
    s.setData({ isRecode: false });


    wx.showToast();
    setTimeout(function () {
      console.log(s.data.recodePath);
      //参考https://segmentfault.com/a/1190000009688541
      //TODO 上传录音文件
    }, 1000)

  }












})